package com.etc.dao.impl;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import com.etc.dao.MoodDao;
import com.etc.entity.Mood;
import com.etc.util.DBUtil;
/**
 * 
 * @author Amber
 *
 */
public class MoodDaoImpl implements MoodDao{

	@Override
	public List<Mood> findAll() {
		List<Mood> list = new ArrayList<Mood>();
		ResultSet rs =DBUtil.query("SELECT mood_id,mood_name FROM mood");
		try {
			while (rs.next()) {
				Integer moodId = rs.getInt("mood_id");
			    String moodName = rs.getString("mood_name");
			    
			    Mood mood = new Mood();
			    mood.setMoodId(moodId);
			    mood.setMoodName(moodName);
			    
			    list.add(mood);
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return list;
	}

}
